import {Message} from "element-ui";
import { req } from './axiosFun';
import request from "../utils/request";
import config from "../../config/config";

export const SyncList = () => { return request.get(config.baseURL + "task/sync"); };

export const TaskList = (params) => { return request.post(config.baseURL + "task/index", params); };

export const TaskSave = (params) => { return request.post(config.baseURL + "task", params); };

export const TaskEdit = (params) => { return request.post(config.baseURL + "task/update", params); };

export const TaskRefresh = (taskid) => { return request.get(config.baseURL + "task/refresh?taskid=" + taskid ); };

export const TaskDelete = (taskid) => { return request.delete(config.baseURL + "task/" + taskid ); };



export const buttonDisable = (button, agentStatus) => {
  if(button === 'signIn') {
    return agentStatus === -1;
  }
  if(button === 'signOut') {
    return agentStatus !== -1;
  }
  if(button === 'status') {

  }
  if(button === 'callIn') {
    return agentStatus !== 0;
  }
  if(button === 'callOut') {
    return agentStatus !== 0;
  }

  if(button === 'calling') {
    return agentStatus !== 2;
  }

  if(button === 'monitor') {
    return agentStatus === -1;
  }
}

export const info = (msg) => {
  new Message({
    type: 'success',
    message: msg
  });
}

export const err = (msg) => {
  new Message({
    type: 'error',
    message: msg
  });
}

export const mapMsg = (msg, defaultMsg) => {
  if(msg === "cann't find callee_agent in map,agent not signin!") {
    return "坐席未登录";
  }
  return defaultMsg;
}
